from enemy import Enemy
from tmap import Map
class Player(object):
    def __init__(self):
        self.hp=10    # your hp
        self.mov=2    # your move
        self.atk=10   # your atk
        self.defend=5     # your defend
        self.damage=0
    def attack(self,enemy):
        a,b=m.getPosition(p)
        c,d=m.getPosition(e)
        if abs(a-c)==1 or abs(b-d)==1:
            self.damage=self.atk-enemy.defend
            enemy.hp=enemy.hp-self.damage
            return enemy.hp
        else:
            print 'no'
            return False


    def move(self,go):
        try:
            a,b=m.getPosition(ppl) 
            if go=='left' and m.tmap[a][b-1]==0:
               
                m.tmap[a][b-1]=ppl
                m.tmap[a][b]=0
                return a,b-1
            
            elif go=='right' and m.tmap[a][b+1]==0:
                
                m.tmap[a][b+1]=ppl
                m.tmap[a][b]=0
                return a,b+1
            
            elif go=='up' and m.tmap[a-1][b]==0:
                 
                m.tmap[a-1][b]=ppl
                m.tmap[a][b]=0
                return a-1,b
            elif go=='down' and m.tmap[a+1][b]==0:
                
                m.tmap[a+1][b]=ppl
                m.tmap[a][b]=0
                return a+1,b
            else:
                print 'No Order'
                return False

        except:
            print 'out of array'
            return False






    
    def isOver(self):
        print 'HP:' ,self.hp
        if self.hp<=0:
            
            print 'dead'
            return True
        else:
            
            print 'live'
            return False

p=Player()
e=Enemy()
m=Map([[0,p,e,0]])
p.attack(e)
print e.hp








